package com.example.dbcenter.intf;

import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

import java.util.Collection;
import java.util.List;
import java.util.Map;

public interface DbOperations {

    // crud
    void insert(Object obj);
    void insert(Object obj, String str);
    /*
        T 代表一种类型
        ?是通配符,泛指所有类型
     */
    void insert(Collection<? extends Object> collection, Class<?> clazz);
    void insert(Collection<? extends Object> collection, String str);
    void insertAll(Collection<? extends Object> collection);

    int delete(Object obj);
    int delete(Object obj, String str);
    int delete(Query query, Class<?> clazz);
    int delete(Query query, Class<?> clazz, String str);
    int delete(Query query, String str);

    int updateOrInsert(Query query, Update upt, Class<?> clazz);
    int updateOrInsert(Query query, Update upt, String str);
    int updateOrInsert(Query query, Update upt, Class<?> clazz, String str);
    int update(Query query, Update upt, Class<?> clazz);
    int update(Query query, Update upt, String str);
    int update(Query query, Update upt, Class<?> clazz, String str);

    <T> T selectOne(Query query, Class<T> tClass);
    <T> T selectOne(Query query, Class<T> tClass, String str);
    Map<String, Object> selectOne(Query query, String str);
    <T> List<T> select(Query query, Class<T> tClass);
    <T> List<T> select(Query query, Class<T> tClass, String str);
    List<Map<String, Object>> select(Query query, String str);

    long count(Query query, Class<?> clazz);
    long count(Query query, String str);

    void destroy();




}
